<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <c:set var="ctx" value="${pageContext.request.contextPath}"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>项目支付表结清明细</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div id="pageInTab" class="pageInTab">
        <form id="formSet1">
            <div class="fieldset1 tabel_col clearFix">
                <div class="fieldBox col_50">
                    <div class="label">融资租赁合同号</div>
                    <div class="field">
                        <span>${prj.lsCntNo}</span>
                        <input name="paySchId" id="paySchId" type="hidden" class="ui-textbox" value="${paySchId}">
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">承租人</div>
                    <div class="field">
                        <span>${prj.cstNm }</span>
                        <%--<span>${cst.cstNm }</span>--%>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">支付表号</div>
                    <div class="field">
                        <a href="javascript:detailBtn()" class="link">
                            <span>${pay.paySchNo}</span>
                        </a>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">结清方式</div>
                    <div class="field">
                        <span id="settleWay" name="settleWay">提前结清</span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">开始期次</div>
                    <div class="field">
                        <span>${pay.startLsPd}</span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label" role="ligertip">自结清期剩余租金合计(元)</div>
                    <div class="field">
		                <span>
		                    <c:if test="${pay.fromSettLastRntAmt==0}">0</c:if>
		                    <c:if test="${pay.fromSettLastRntAmt!=0}">
                                <fmt:formatNumber type="number" value="${pay.fromSettLastRntAmt}" pattern=".00"/>
                            </c:if>
		                </span>
                    </div>
                </div>
                <!-- -->
                <%--<div class="fieldBox col_50">
                    <div class="label">保险保证金处理状态</div>
                    <div class="field">
                        <span>${pay.insDepHandleWayCdNm}</span>
                    </div>
                </div>--%>
                <div class="fieldBox col_50">
                    <div class="label">保险保证金(元)</div>
                    <div class="field">
		                <span>
		                    <c:if test="${pay.insDep!=0}">
                                <fmt:formatNumber type="number" value="${pay.insDep}" pattern="#.00"/>
                            </c:if>
		                    <c:if test="${pay.insDep==0}">0</c:if>
		                </span>
                    </div>
                </div>
                <%--<div class="fieldBox col_50">
                    <div class="label">客户保证金处理状态</div>
                    <div class="field">
                        <span>${pay.detHandleWayCdNm}</span>
                    </div>
                </div>--%>
                <div class="fieldBox col_50">
                    <div class="label">客户保证金(元)</div>
                    <div class="field">
		                <span>
		                    <c:if test="${pay.detAmt==0}">0</c:if>
		                    <c:if test="${pay.detAmt!=0}">
                                <fmt:formatNumber type="number" value="${pay.detAmt}" pattern=".00"/>
                            </c:if>
		                </span>
                    </div>
                </div>

                <div class="fieldBox col_50">
                    <div class="label">优惠金额(元)</div>
                    <div class="field">
		                <span>
		                    <c:if test="${pay.discountAmt==0}">0</c:if>
		                    <c:if test="${pay.discountAmt!=0}">
                                <fmt:formatNumber type="number" value="${pay.discountAmt}" pattern=".00"/>
                            </c:if>
		                </span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label" role="ligertip">结清开始时间前每期应还租金合计(元)</div>
                    <div class="field">
		                  <span>
		                    <c:if test="${pay.beforeSettRntAmt==0}">0</c:if>
		                    <c:if test="${pay.beforeSettRntAmt!=0}">
                                <fmt:formatNumber value="${pay.beforeSettRntAmt}" pattern="#.00"/>
                            </c:if>
		                 </span>
                    </div>
                </div>

                <div class="fieldBox col_50">
                    <div class="label">违约金(元)</div>
                    <div class="field">
		                <span>
		                    <c:if test="${pay.breachAmt==0}">0</c:if>
		                    <c:if test="${pay.breachAmt!=0}">
                                <fmt:formatNumber type="number" value="${pay.breachAmt}" pattern=".00"/>
                            </c:if>
		               </span>
                    </div>
                </div>
                <!-- 无逾期时显示 -->
                <div id="beforeSetteRntAmt" style="display: none">
                    <div class="fieldBox col_50">
                        <div class="label" role="ligertip">未到支付日期已还款金额合计(元)</div>
                        <div class="field">
		                  <span>
		                     <c:if test="${pay.totalActRntAmt==0}">0</c:if>
		                    <c:if test="${pay.totalActRntAmt!=0}">
                                <fmt:formatNumber type="number" value="${pay.totalActRntAmt}" pattern=".00"/>
                            </c:if>
		                  </span>
                        </div>
                    </div>
                </div>
                <div class="fieldBox col_100">
                    <div class="label">最终应还金额公式</div>
                    <div class="field">
                        <c:if test="${pay.penaltyAmt!=0&&yzdgFlag==0 }">
                            <span style="color: red">结清前应还的每期租金合计 + 末期租金 + 违约金 + 罚息 + 其他费用 - 违约金减免 –未到支付日期已还款金额合计 + 未核销借款金额</span>
                        </c:if>
                        <c:if test="${pay.penaltyAmt==0&&yzdgFlag==0 }">
                            <span style="color: red">结清前应还的每期租金合计 + 自结清期剩余租金合计 + 逾期罚息 + 其他费用 - 保证金 - 保险保证金 - 逾期当期已还款金额 + 未核销借款金额</span>
                        </c:if>
                        <c:if test="${yzdgFlag==1}">
                            <span style="color: red">逾期租金+应收罚息+剩余本金+剩余利息-优惠金额（租金总额百分比，看主合同7.4）</span>
                        </c:if>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">逾期期次</div>
                    <div class="field">
                        <span>${pay.overduePd}</span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">到今天逾期租金(元)</div>
                    <div class="field">
		                <span>
		                    <c:if test="${pay.overdueAmt==0}">0</c:if>
		                    <c:if test="${pay.overdueAmt!=0}">
                                <fmt:formatNumber value="${pay.overdueAmt}" pattern="#.00"/>
                            </c:if>
		                </span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">逾期罚息</div>
                    <div class="field">
		                <span>
		                    <c:if test="${pay.penaltyAmt==0}">0</c:if>
		                    <c:if test="${pay.penaltyAmt!=0}">
                                <fmt:formatNumber type="number" value="${pay.penaltyAmt}" pattern=".00"/>
                            </c:if>
		                </span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label" role="ligertip">逾期当期已还款金额(元)</div>
                    <div class="field">
		                <span>
		                    <c:if test="${pay.actualAmt==0}">0</c:if>
		                    <c:if test="${pay.actualAmt!=0}">
                                <fmt:formatNumber type="number" value="${pay.actualAmt}" pattern=".00"/>
                            </c:if>
		                </span>
                    </div>
                </div>

                <div class="fieldBox col_100">
                    <div class="label"> 最终应还金额(元)</div>
                    <div class="field">
		                <span>
		                    <c:if test="${pay.finalPayAmt==0}">0</c:if>
		                    <c:if test="${pay.finalPayAmt!=0}">
                                <fmt:formatNumber type="number" value="${pay.finalPayAmt}" pattern=".00"/>
                            </c:if>
		                </span>
                    </div>
                </div>

                <div class="caption">
                    <span class="title">已付款项明细信息</span>
                </div>

                <div class="fieldBox col_100">
                    <div class="sqPanel">
                        <div id="detailGrid">
                            <div id="ligergrid_fee" class="sq-grid"></div>
                        </div>
                    </div>
                </div>
                <div class="fieldBox col_100">
                    <div class="sqPanel">
                        <div>
                            <div id="ligergrid_payAmt" class="sq-grid sq-grid-noTitle"></div>
                        </div>
                    </div>
                </div>
                <div class="fieldBox col_100">
                    <div class="label">来款合计</div>
                    <div class="field">
		                <span>
		                    <c:if test="${pay.totalActPrinAmt+pay.totalActIntAmt==0}">0</c:if>
		                    <c:if test="${pay.totalActPrinAmt+pay.totalActIntAmt!=0}">
                                <fmt:formatNumber value="${pay.totalActPrinAmt+pay.totalActIntAmt}" pattern="#.00"/>
                            </c:if>
		                </span>
                    </div>
                </div>
                <div class="caption">
                    <span class="title">应还项目信息</span>
                </div>
                <div class="fieldBox col_100">
                    <div class="sqPanel">
                        <div>
                            <div id="ligergrid_shouldPay" class="sq-grid sq-grid-noTitle"></div>
                        </div>
                    </div>
                </div>

                <%-- 结清费用项操作页面 --%>
                <jsp:include page="../../settlement/mdfSettleFeeCommon.jsp"/>

                <div class="caption">
                    <span class="title">核算金额校验</span>
                </div>
                <div class="fieldBox col_100">
                    <div class="sqPanel">
                        <div>
                            <div id="ligergrid_checkAmt" class="sq-grid sq-grid-noTitle"></div>
                        </div>
                    </div>
                </div>
                <div class="fieldBox col_100">
                    <div class="sqPanel">
                        <div id="feePayGrid">
                            <div id="ligergrid_calculate" class="sq-grid"></div>
                        </div>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">合计租金</div>
                    <div class="field">
		                <span id="totalRntAmt">
		                    <fmt:formatNumber type="number" value="${pay.totalRntAmt}" pattern=".00"/>
		                </span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">合计本金</div>
                    <div class="field">
		                <span id="totalPrinAmt">
		                    <fmt:formatNumber type="number" value="${pay.totalPrinAmt}" pattern=".00"/>
		                </span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">合计利息</div>
                    <div class="field">
		                <span id="totalIntAmt">
		                    <fmt:formatNumber type="number" value="${pay.totalIntAmt}" pattern=".00"/>
		                </span>
                    </div>
                </div>
            </div>
            <div class="fieldBox col_50" isYZDG="yzdg" style="display: none">
                <div class="label">优惠开始期次</div>
                <div class="field">
                    <select id="reduStartLsPd" disabled="disabled">
                        <c:forEach begin="${pay.startLsPd}" end="${payPd}" step="1" var="pd">
                            <option value="${pd}"
                                    <c:if test="${pd==reduStartLsPd}"> selected="selected"</c:if>
                            >第${pd}期
                            </option>
                        </c:forEach>
                    </select>
                </div>
            </div>
            <div class="fieldBox col_33" isYZDG="yzdg" style="display: none">
                <div class="label">开始结清期次12期（不含）之后剩余租金</div>
                <div class="field">
                    <span id="totalRentAmt">${after12LastRntAmt}</span>
                </div>
            </div>
            <div class="fieldBox col_50" isYZDG="yzdg" style="display: none">
                <div class="label">结清比例</div>
                <div class="field">
                    <select name="settPct" id="settPct" disabled="disabled">
                        <c:forEach items="${settPctList}" var="opt">
                            <option value="${opt.key}"
                                    <c:if test="${opt.key==settPctValue}">selected="selected"</c:if>
                            >${opt.value}</option>
                        </c:forEach>
                    </select>
                </div>
            </div>
            <div class="fieldBox col_33" isYZDG="yzdg" style="display: none">
                <div class="label">合同外优惠金额</div>
                <div class="field">
                    <input name="extContAmt" id="extContAmt" type="text" class="ui-textbox" value="${extContAmt}"
                           readonly="readonly">
                </div>
            </div>
            <div class="fieldBox col_33" isYZDG="yzdg" style="display: none">
                <div class="label">合同内优惠金额</div>
                <div class="field">
                    <input name="reduAmt" id="reduAmt" type="text" class="ui-textbox" value="${reduAmt-extContAmt}"
                           readonly="readonly">
                </div>
            </div>
            <div class="fieldBox col_33" isYZDG="yzdg" style="display: none">
                <div class="label">优惠金额总计</div>
                <div class="field">
                    <input name="reduTotalAmt" id="reduTotalAmt" type="text" class="ui-textbox"
                           value="${reduAmt+extContAmt}">
                </div>
            </div>

            <%--附件--%>
            <jsp:include page="../../settlement/settleFile.jsp" flush="true">
                <jsp:param name="pkId" value="${pay.id}"/>
                <jsp:param name="filePath" value="prjprdpayschm"/>
                <jsp:param name="optAuth" value="1"/>
            </jsp:include>

            <div class="btnsBox">
                <c:if test="${showStlBtn == 1}">
                    <span id="saveBtn1" class="sq-button sq-button-round">提前结清</span>
                </c:if>
            </div>
        </form>
    </div>
</div>

<script type="text/javascript">
    var basePath = '<%=path%>';
    var feeGrid;//费用明细信息
    var paySchId = '${paySchId}';
    var calculateGrid;//支付明细
    var subFeeAmt = '${subFeeAmtTotalList}';
    subFeeAmt = JSON.parse(subFeeAmt);
    var payAmtGrid;
    var shouldPayGrid;
    var checkAmtGrid;
    var yzdgFlag = '${yzdgFlag}';
    var zckcFlag = '${zckcFlag}';
    $(function () {
        // 隐藏费用项操作
        $(".operation").hide();
        $('#formSet1').ligerForm({
            validate: true
        });
        if (yzdgFlag == 1) {
            $("div[isYZDG='yzdg']").each(function () {
                $(this).show();
            });
            if (liger.get("settPct") && liger.get("settPct") != "undefined") {
                liger.get("settPct").setDisabled(true);
            }
        }
        var listPage = '${listPage}';
        var feeListPage = '${feeListPage}'.replace(/[\r]/g, "\\r").replace(/[\n]/g, "\\n");
        var checkAmtData = {
            "rows": [
                {
                    "feeTypCdNm": "支付表本金合计",
                    "feeAmt": '${pay.totalPrinAmt}',
                    "paidUpAmt": ""
                },
                {
                    "feeTypCdNm": "支付表利息合计",
                    "feeAmt": '${pay.totalIntAmt}',
                    "paidUpAmt": ""
                },
                {
                    "feeTypCdNm": "核算金额校验",
                    "feeAmt": '${pay.checkPayAmt}',
                    "paidUpAmt": ""
                }

            ],
            "total": 3
        }
        var payAmtData = {
            "rows": [
                {
                    "feeTypCdNm": "本金",
                    "feeAmt": '${pay.totalPrinAmt}',
                    "paidUpAmt": "${pay.totalActPrinAmt}"
                },
                {
                    "feeTypCdNm": "利息",
                    "feeAmt": '${pay.totalIntAmt}',
                    "paidUpAmt": "${pay.totalActIntAmt}"
                },
                {
                    "feeTypCdNm": "已交罚息合计",
                    "feeAmt": '${pay.penaltyAmt}',
                    "paidUpAmt": "${pay.payAmount}"
                }

            ],
            "total": 3
        }

        var shouldPayData = {
            "rows": [
                {
                    "feeTypCdNm": "风险保证金",
                    "feeAmt": '${pay.rickDep}',
                    "paidUpAmt": ""
                },
                {
                    "feeTypCdNm": "截止发起日应交逾期租金",
                    "feeAmt": '${pay.overdueAmt}',
                    "paidUpAmt": ""
                },
                {
                    "feeTypCdNm": "截止发起日应交逾期罚息",
                    "feeAmt": '${pay.penaltyAmt}',
                    "paidUpAmt": ""
                },
                {
                    "feeTypCdNm": "自结清期剩余本金",
                    "feeAmt": '${pay.lastPrintAmt}',
                    "paidUpAmt": ""
                },

                {
                    "feeTypCdNm": "自结清期剩余利息",
                    "feeAmt": '${pay.lastIntAmt}',
                    "paidUpAmt": ""
                }
            ],
            "total": 0
        }
        for (var i = 0; i < subFeeAmt.length; i++) {
            var obj = subFeeAmt[i];
            var json = {};
            json.feeTypCdNm = obj.feeTypCdNm;
            json.feeAmt = obj.feeAmt;
            json.paidUpAmt = obj.paidUpAmt;
            json.capFlow = obj.capFlow;
            shouldPayData.rows.push(json);
        }


        listPage = JSON.parse(listPage);
        feeListPage = JSON.parse(feeListPage);
        prjQuatPrpsfeeGrid(feeListPage);
        initCalculatePage(listPage);
        prjPrdPayCheckAmtGrid(checkAmtData);
        prjPrdPayShouldPayGrid(shouldPayData);
        prjPrdPayPayAmtGrid(payAmtData);

        var penaltyAmt = '${pay.penaltyAmt}';
        if (penaltyAmt != 0) {
            $("#beforeSetteRntAmt").show();
        }


    });

    function detailBtn() {
        var editFlag = true;
        var prjId = '${dtl.prjId}';
        var prjPrdDtlId = '${dtl.id}';
        var prjPrdId = '${dtl.prjPrdId}';
        var paySchId = '${paySchId}';
        Add_navTab('tab_prj_quat_prps' + paySchId, '查看支付表', basePath + '/project/prjprdpayschm/toAddPage.do?prjId=' + prjId + '&&id=' + paySchId + '&&prjPrdDtlId=' + prjPrdDtlId + '&&prjPrdId=' + prjPrdId + '&&detailFlag=' + editFlag);
    }

    function prjPrdPayCheckAmtGrid(data) {
        checkAmtGrid = $("#ligergrid_checkAmt").ligerGrid({
            data: data,
            columns: [
                {display: '项目', name: 'feeTypCdNm', minWidth: 140},
                {display: '应收金额(元)', name: 'feeAmt', minWidth: 140, render: renderAmt, type: 'currency'},
                {
                    display: '已收金额(元)', name: 'paidUpAmt',
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        if (value) {
                            h = value / 100;
                        }
                        h = "￥" + FormatMoney((parseFloat(h)).toFixed(2));
                        return h;
                    },
                    minWidth: 60, render: renderAmt, type: 'currency'
                }
            ],
            usePager: false,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            heightDiff: -2,
            enabledEdit: false,
            isScroll: false,
            checkbox: false,
            rownumbers: true,
            frozen: false,
            allowUnSelectRow: false,
            alternatingRow: false
        });
    }

    function prjPrdPayShouldPayGrid(data) {
        shouldPayGrid = $("#ligergrid_shouldPay").ligerGrid({
            data: data,
            columns: [
                {display: '项目', name: 'feeTypCdNm', minWidth: 140},
                {
                    display: '应收金额(元)', name: 'feeAmt', minWidth: 140,
                    render: function (item) {
                        var amt = item.feeAmt;
                        if (item.capFlow == ProjectConstant.CODE_PRJ_QUAT_CASH_FLOW_OUT) {
                            amt = "<span style='color:red'>-" +
                                "￥" + FormatMoney((parseFloat(item.feeAmt)).toFixed(2))
                                + "</span>";
                        } else {
                            amt = "￥" + FormatMoney((parseFloat(item.feeAmt)).toFixed(2));
                        }
                        return amt;
                    }
                },
                {display: '已收金额(元)', name: 'paidUpAmt', minWidth: 60, type: 'currency'}
            ],
            usePager: false,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            heightDiff: -2,
            enabledEdit: false,
            isScroll: false,
            checkbox: false,
            rownumbers: true,
            frozen: false,
            allowUnSelectRow: false,
            alternatingRow: false
        });
    }

    function prjPrdPayPayAmtGrid(data) {
        payAmtGrid = $("#ligergrid_payAmt").ligerGrid({
            data: data,
            columns: [
                {display: '项目', name: 'feeTypCdNm', minWidth: 140},
                {display: '应收金额(元)', name: 'feeAmt', minWidth: 140, render: renderAmt, type: 'currency'},
                {display: '已收金额(元)', name: 'paidUpAmt', minWidth: 60, render: renderAmt, type: 'currency'}
            ],
            usePager: false,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            heightDiff: -2,
            enabledEdit: false,
            isScroll: false,
            checkbox: false,
            rownumbers: true,
            frozen: false,
            allowUnSelectRow: false,
            alternatingRow: false
        });
    }

    function prjQuatPrpsfeeGrid(data) {
        feeGrid = $("#ligergrid_fee").ligerGrid({
            data: data,
            columns: [
                {display: '项目', name: 'feeTypCdNm', minWidth: 140},
                {display: '应收金额(元)', name: 'feeAmt', minWidth: 140, render: renderAmt, type: 'currency'},
                {
                    display: '已收金额(元)', name: 'paidUpAmt', minWidth: 60,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        if (value) {
                            h = value / 100;
                        }
                        h = "￥" + FormatMoney((parseFloat(h)).toFixed(2));
                        return h;
                    },
                    type: 'currency'
                }
            ],
            usePager: false,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: 300,
            heightDiff: -2,
            enabledEdit: false,
            isScroll: false,
            checkbox: false,
            rownumbers: true,
            allowUnSelectRow: false,
            alternatingRow: false
        });
    }

    function initCalculatePage(data) {
        calculateGrid = $("#ligergrid_calculate").ligerGrid({
            data: data,
            columns: [
                {display: '支付时间', name: 'payDt', render: renderDate, minWidth: 60},
                {display: '期次', name: 'payPd', minWidth: 140},
                {display: '租金', name: 'rntAmt', minWidth: 140, render: renderAmt, type: 'currency', enabledSort: true},
                {display: '本金', name: 'prinAmt', minWidth: 60, render: renderAmt, type: 'currency'},
                {display: '利息', name: 'intAmt', minWidth: 140, render: renderAmt, type: 'currency'},
                {display: '剩余本金', name: 'remPrinAmt', minWidth: 140, render: renderAmt, type: 'currency'},
            ],
            usePager: false,
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: 300,
            heightDiff: -2,
            //isScroll: false,
            checkbox: false,
            enabledEdit: false,
            rownumbers: true
        });
    }

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }

    $("#saveBtn1").click(function (event) {
        //添加发起确认的提示
        $.ligerDialog.confirm("确定要发起提前结清吗？", function (flag) {
            if (flag == false) return;
            var data = {};
            data["paySchId"] = paySchId;
            //var calculateData = calculateGrid.getData();
            //data["payList"] = JSON.stringify(calculateData);
            data["totalSettAmt"] = $("#totalSettAmt").text();
            data["settFlag"] = "pre";
            data["discountAmt"] = '${pay.discountAmt}';
            data["breachAmt"] = '${pay.breachAmt}';
            data["payPd"] = '${pay.startLsPd}';
            var url = basePath + '/project/prjprdpayschm/applyPreSett.do';
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: data,
                url: url,
                beforeSend: function () {
                    wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                },
                success: function (msg) {
                    wait_dialog.close();
                    if (msg.success == 1) {
                        $.ligerDialog.SQalert({
                            SQ_showButtons: true,
                            content: msg.info
                        });
                    } else {
                        UIUtils.alertErrorHold1(msg.info);
                    }
                }
            });
        });
    });

    //格式化为人民币格式
    function renderAmt(rowdata, rowindex, value) {
        if (null !== value && value !== 'undefined' && value !== "") {
            if (typeof Number(value) == 'number') {
                var h = "￥" + FormatMoney((parseFloat(value)).toFixed(2));
                return h;
            }
        }
    }

    /*function setLastRnt() {
        var data = {};
        data.paySchId = paySchId;
        data.reduStartLsPd = $("#reduStartLsPd").val();
        var url = basePath + '/project/prjPrdPaySchM/getTotalRntAmtByPayPd.do.do';
        var wait_dialog;
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: data,
            url: url,
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {
                    $("#after12LastRntAmt").text(msg.data);
                    setReduAmtValue();
                } else {
                    $.ligerDialog.SQalert({content: "保存失败！", SQ_type: "error"});
                }
            }
        });
    }*/

    function setReduAmtValue() {
        if (yzdgFlag && yzdgFlag == 1) {
            var after12LastRntAmt = parseFloat($("#after12LastRntAmt").text());
            var settPct = parseFloat($("#settPct").val() / 100);
            var extContAmt = parseFloat($("#extContAmt").val());
            var reduAmtValue = parseFloat(after12LastRntAmt * (1 - settPct) + extContAmt).toFixed(2);
            $("#reduAmt").val(parseFloat(after12LastRntAmt * (1 - settPct)).toFixed(2));
            $("#reduTotalAmt").val(reduAmtValue);
            var beforeReduAmt = '${reduAmt}';
            var settAmt = '${pay.totalSettAmt}';
            if (parseFloat(beforeReduAmt) != parseFloat(reduAmtValue)) {
                var amt = parseFloat(settAmt - reduAmtValue).toFixed(2);
                $("#finalPayAmt").text(amt);
                $("#totalSettAmt").text(amt);
            }
        }
    }
</script>


</body>
</html>
